
<%@ page import="projetstackoverflow.Question" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'question.label', default: 'Question')}" />
		<title><g:message code="default.list.label" args="[entityName]" /></title>
	</head>
	<body>
		<div id="questions-list">
		<g:each var="c" in="${questionInstanceList}">
			<div class="question">
				<div class="left-part">
					<g:link class="votes" controller="question" action="show" id="${c.id}">
						<g:message code="question.list.votes" args="${[c.countVotes()]}"/>
					</g:link>
					
					<g:link class="answers ${
						for(def ans : c.answers) 
							if(ans.selected) 
								return 'selected'; 
						if(c.answers.size() > 0)
							return 'answered'
						else
							return ''
							}" controller="question" action="show" id="${c.id}">
						<g:message code="question.list.answers" args="${[c.answers.size()]}"/>
					</g:link>
					
					<g:link class="views" controller="question" action="show" id="${c.id}">
						<g:message code="question.list.views" args="${[c.viewsNumber]}"/>
					</g:link>
				</div>
				<div class="right-part">
					<div class="title-question">
						<g:link controller="question" action="show" id="${c.id}">
						${c.title}
						</g:link>
					</div>
				     <div class="author-question">
				    	<i>
					    	<g:message code="default.questions.askedAgo1"/>
					    	<g:ago time="${c.date}"/>
					    	<g:message code="default.questions.askedAgo2"/>
					    	<g:link controller="author" action="show" id="${c.author.id}">
					    		${c.author.pseudo }
					    	</g:link>
				    	</i>
				    </div>
				    <g:tagList id="${c.id }" />
				</div>
			</div>
		</g:each>
	</div>
	<div class="pagination">
	<g:paginate controller="question" action="list" total="${questionInstanceTotal}" params="${['idTag':params.idTag, 'idAuthor':params.idAuthor]}" />
	</div>
				
	</body>
</html>
